package org.cskj.demo.service.imp;

import org.cskj.demo.mapper.ShoptypeMapper;
import org.cskj.demo.pojo.Shoptype;
import org.cskj.demo.pojo.ShoptypeExample;
import org.cskj.demo.service.ShopTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShopTypeImp implements ShopTypeService {
   @Autowired
    private ShoptypeMapper shoptypeMapper;

    @Override
    public List<Shoptype> selectAll() {
        return shoptypeMapper.selectByExample(null);
    }
    public int insert(Shoptype shoptype){
        int i = shoptypeMapper.insertSelective(shoptype);
        return i;
    }
    public List<Shoptype> check(String name){
        ShoptypeExample example = new ShoptypeExample();
        ShoptypeExample.Criteria criteria = example.createCriteria();
        criteria.andShoptypenameEqualTo(name);
        List<Shoptype> shoptypes = shoptypeMapper.selectByExample(example);
        return shoptypes;
    }
    public boolean checkname(String shoptypename){
        ShoptypeExample example = new ShoptypeExample();
        ShoptypeExample.Criteria criteria = example.createCriteria();
        criteria.andShoptypenameEqualTo(shoptypename);
        List<Shoptype> shoptypes = shoptypeMapper.selectByExample(example);
        if (shoptypes.size()>0){
            return false;
        }else {
            return true;
        }
    }
    public int update(Shoptype shoptype){
        int i = shoptypeMapper.updateByPrimaryKey(shoptype);
        return i;
    }
    public int  delete(int shoptypeid){
        int i = shoptypeMapper.deleteByPrimaryKey(shoptypeid);
        return i;
    }
}
